# import zbar
# import pyzxing
from pyzxing import BarCodeReader


# from PIL import Image

# from appdirs import unicode

# 指定文件识别
def decode(imgfile):
    reader = BarCodeReader()
    results = reader.decode(imgfile)
    return results
    # data = u''
    # for symbol in image:
    #     data += symbol.data.decode('utf-8')
    #
    # del (image)
    #
    # if data:
    #     return unicode(data)
    # else:
    #     return u"解析失败!\n确定上传的是二维码图片吗?!"


# 批量指定文件夹下.png格式 支持一图多码
def decodesPng(path):
    reader = BarCodeReader()
    results = reader.decode(path + '/*.png')
    return results


# 批量指定文件夹下.jpg格式
def decodesJpg(path):
    reader = BarCodeReader()
    results = reader.decode(path + '/*.jpg')
    return results
